# -*- coding: utf-8 -*-
# @File: backend => room_schema.py
# @CreateTime: 2025/8/26 19:40
# @Author: EvanZhang
# @Info: 房间相关的Pydantic模型
from pydantic import BaseModel, Field
from typing import Optional, List
from datetime import datetime

class RoomBase(BaseModel):
    id: int
    name: str
    sb: int
    bb: int
    max_players: int
    status: str

class RoomCreateRequest(BaseModel):
    name: str = Field(..., max_length=50, description="房间名称")
    sb: int = Field(..., gt=0, description="小盲注")
    bb: int = Field(..., gt=0, description="大盲注")
    max_players: int = Field(..., gt=1, le=10, description="最大玩家数")
    pwd: Optional[str] = None  # 密码可选

class RoomJoinRequest(BaseModel):
    buy_in_amount: int = Field(..., gt=0, description="买入筹码数量")

class RoomJoinResponse(BaseModel):
    seat_index: int = Field(..., description="座位索引")
    buy_in_chips: int = Field(..., description="买入筹码数量")

class SeatInfo(BaseModel):
    user_id: int = Field(..., description="用户ID")
    username: str = Field(..., description="用户名")
    chips_on_table: int = Field(..., description="桌上筹码")
    state: str = Field(..., description="玩家状态")
    last_action: Optional[str] = Field(None, description="最后动作")
    avatar_url: Optional[str] = Field(None, description="头像URL")

class RoomLeaveResponse(BaseModel):
    msg: str = Field(..., description="离开房间结果消息")

class RoomSnapshotResponse(BaseModel):
    id: int = Field(..., description="房间ID")
    name: str = Field(..., description="房间名称")
    sb: int = Field(..., description="小盲注")
    bb: int = Field(..., description="大盲注")
    max_players: int = Field(..., description="最大玩家数")
    status: str = Field(..., description="房间状态")
    seats: List[Optional[SeatInfo]] = Field(..., description="座位信息")
    board: List[str] = Field(..., description="公共牌")
    pots: dict = Field(..., description="奖池信息")
    to_act_seat: Optional[int] = Field(None, description="当前行动座位")
    action_deadline: Optional[int] = Field(None, description="行动截止时间")



